package com.message.source;

import com.qcloud.sms.SmsMultiSender;
import com.qcloud.sms.SmsMultiSenderResult;
import com.qcloud.sms.SmsSingleSender;
import com.qcloud.sms.SmsSingleSenderResult;

import java.util.ArrayList;

public class SmsSDKDemo {

    public void messageClient(String phoneNumber, int random) {

        try {

            int appid = 1400036402;
            String appkey = "99407e02cf8515dcbc8a142b15d834f1";
            SmsSingleSender singleSender = new SmsSingleSender(appid, appkey);
            SmsSingleSenderResult singleSenderResult;
            singleSenderResult = singleSender.send(0, "86", phoneNumber, "感谢使用广东珠江开关有限公司的互联网产品，该产品在线验证码为：" + random + "。", "", "");
            //singleSenderResult = singleSender.send(0, "86", phoneNumber, "【广东珠江开关有限公司】您的验证码码为："+ random+ "本验证码15分钟内有效，感谢您的使用！", "", "");
            System.out.println(singleSenderResult);

        } catch (Exception e) {
            e.printStackTrace();
        }


    }

    public void messageClient2(String phoneNumber, int random) {


        int appid = 1400036402;
        String appkey = "99407e02cf8515dcbc8a142b15d834f1";
        SmsMultiSender multiSender = null;
        try {
            multiSender = new SmsMultiSender(appid, appkey);
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        SmsMultiSenderResult multiSenderResult;
        ArrayList<String> phoneNumbers = new ArrayList<String>();
        phoneNumbers.add(phoneNumber);
        ArrayList<String> params = new ArrayList<String>();
        int tmplId = 1278976;
        params.add("ZKP51-63H中111111111160号设备");
        params.add("漏电故障");

        try {
            multiSenderResult = multiSender.sendWithParam("86", phoneNumbers, tmplId, params, "", "", "");
            System.out.println(multiSenderResult);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


    }
    public void messageClient3(String phoneNumber, String number, String fault) {

        if (phoneNumber.isEmpty()) {
            return;
        }
        int appid = 1400036402;
        String appkey = "99407e02cf8515dcbc8a142b15d834f1";
        SmsMultiSender multiSender = null;
        try {
            multiSender = new SmsMultiSender(appid, appkey);
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        SmsMultiSenderResult multiSenderResult;
        ArrayList<String> phoneNumbers = new ArrayList<String>();
        phoneNumbers.add(phoneNumber);
        ArrayList<String> params = new ArrayList<String>();
        int tmplId = 326566;
       /* {1}您好！{2}中的{3}已出现{4}，请检修！*/
        params.add("尊敬的用户");
        params.add("您的ZKP51-63H防火防雷漏电断路器");
        params.add(number+ "号设备");
        params.add(fault);

        try {
            multiSenderResult = multiSender.sendWithParam("86", phoneNumbers, tmplId, params, "", "", "");
            System.out.println(multiSenderResult);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


    }

}
